home *** CD-ROM | disk | FTP | other *** search
/ BMUG PD-ROM A / PD-ROM A.iso / Programming / Programming Languages / Gambit LISP / OPEN ME FIRST! < prev    next >
Encoding:
Text File  |  1991-01-28  |  11.4 KB  |  339 lines  |  [TEXT/gamI]

  1. Documentation for Gambit v1.51 for Macintosh
  2. --------------------------------------------
  3.  
  4. In this documentation, you will find information on the following
  5. applications:
  6.  
  7. - Gambit Interpreter
  8. - Gambit Compiler
  9. - Gambit Linker
  10.  
  11. All of these applications run on Mac+/SE/II computers.
  12.  
  13.  
  14. Gambit Interpreter
  15. ------------------
  16.  
  17. The Gambit Interpreter (GSI for short) is a Scheme interpreter that
  18. can be used to develop and debug Gambit Scheme programs.  GSI conforms
  19. to the IEEE-Scheme standard as well as the R3.99RS report.  In
  20. addition, GSI has the ability to dynamically load object files (i.e.
  21. files with a .O extension) produced by the Gambit compiler.  GSI has a
  22. minimal debugging environment that supports program interrupt, error
  23. resume and abort.  Gambit v1.51 implements exact arithmetic only
  24. (including bignums and rationals).  Real and complex numbers are not
  25. available.
  26.  
  27. When GSI is launched, it grabs the entire memory for its heap (GSI can
  28. run with as little as 1 Meg of memory).  Under Multifinder it is
  29. possible to limit the amount of memory used by GSI by changing GSI's
  30. memory requirement information with the finder's <cmd>-I command.
  31.  
  32. If present, the file "init.scm" is loaded when GSI is launched.  This
  33. file can be used to customize GSI to your own needs.
  34.  
  35. Most of the interaction with GSI's read-eval-print (REP) loop is done
  36. through the keyboard.  To evaluate an expression, place the caret
  37. after the end of the expression and press <enter>.  This will send the
  38. expression to the interpreter for evaluation and the result will be
  39. displayed in the interaction window.  In addition, it is possible to
  40. send arbitrary text to the interpreter by selecting it before pressing
  41. <enter>.  These evaluation mechanisms also work in windows attached to
  42. files (however the result is always displayed in the interaction
  43. window).  For example, if you are reading this file from GSI, place the
  44. caret after the closing parenthesis of (* 3 5) and press <enter>.  The
  45. value 15 should be printed on the interaction window.
  46.  
  47. The tab key can be used to move the caret to the appropriate indentation
  48. position.
  49.  
  50. Special keyboard commands are available to interact with the
  51. interpreter:
  52.  
  53. - <cmd>-.  Interrupts the current computation and starts a new REP loop
  54. - <cmd>-R  Resumes an interrupted computation
  55. - <cmd>-D  Returns to the previous REP loop (also acts as end-of-file)
  56. - <cmd>-T  Returns to the top-most REP loop
  57.  
  58.  
  59. Here is a transcript of a typical interaction with GSI (comments are
  60. marked with ";;;" and user input is in bold):
  61.  
  62. Gambit (v1.51)
  63.  
  64. Loading "init.scm"
  65.  
  66. : ®ÏÔ·‰ ¢Ê·„Ù¢©  ;;; load "fact.scm" file
  67. "fact.scm"
  68.  
  69. : ®Ê·„Ù ¥∞©  ;;; try it
  70. 815915283247897734345611269596115894272000000000
  71.  
  72. : ®ÙÚ·„ ʷ„Ù©  ;;; lets trace what fact is doing
  73. fact
  74.  
  75. : ®Ê·„Ù ±µ©
  76. |(fact 15)
  77. | (fact 14)
  78. |  (fact 13)
  79. |   (fact 12)
  80. |    (fact 11)
  81. |    |(fact 10)
  82. |    | (fact 9)
  83. |    |  (fact 8)
  84. |    |   (fact 7)
  85. |    |    (fact 6)
  86. |    |    |(fact 5)
  87. |    |    | (fact 4)
  88. |    |    |  (fact 3)
  89. |    |    |   (fact 2)
  90. |    |    |    (fact 1)
  91. |    |    |    <== 1
  92. |    |    |   <== 2
  93. |    |    |  <== 6
  94. |    |    | <== 24
  95. |    |    |<== 120
  96. |    |    <== 720
  97. |    |   <== 5040
  98. |    |  <== 40320
  99. |    | <== 362880
  100. |    |<== 3628800
  101. |    <== 39916800
  102. |   <== 479001600
  103. |  <== 6227020800
  104. | <== 87178291200
  105. |<== 1307674368000
  106. 1307674368000
  107.  
  108. : ®ÏÔ·‰ ¢È¢©  ;;; load "pi.O" file
  109. How many digits of pi do you want (0 to exit): ∑∞
  110. 3.1415926535897932384626433832795028841971693993751058209749445923078164
  111. How many digits of pi do you want (0 to exit): ∞
  112. "pi.O"
  113.  
  114. : ®ÒıÂÂÓÛ ∏ £Ù©  ;;; oops!, we haven't defined it yet...
  115.  
  116. *** ERROR, Unbound variable: queens
  117.  
  118.  
  119. 1:   ;;; user typed <cmd>-D here
  120. : ®ÏÔ·‰ ¢ÒıÂÂÓÛ¢©  ;;; load it!
  121. "queens.O"
  122.  
  123. : ®ÒıÂÂÓÛ ∏ £Ù©
  124. (4 2 7 3 6 8 5 1)
  125. (5 2 4 7 3 8 6 1)
  126. (3 6 4 2 8 5 7 1)
  127. (3 5 2 8 6 4 7 1)
  128. (5 7 1 3 8 6 4 2)
  129. (4 6 8 3 1 7 5 2)
  130. (3 6 8 1 4 7 5 2)
  131. (5 7 4 1 3 8 6 2)
  132. (5 3 8 4 7 1 6 2)
  133. (3 6 4 1 8 5 7 2)  ;;; user typed <cmd>-. here
  134.  
  135. *** INTERRUPT
  136.  
  137.  
  138. 1:   ;;; <cmd>-D
  139. : ®ÏÔ·‰ ¢ÙÚ¢©
  140. "tree.scm"
  141.  
  142. : ®ÙÚÂÂ≠‰ÈÛÏ·˘ ®„·ÏÏ≠˜ÈÙË≠ÈÓıÙ≠ÊÈÏ ¢Ê·„ÙÆÛ„Ì¢ Ú·‰©©
  143.               .                                             
  144.    .----------------------.                                 
  145.    .                      .                                 
  146. define     .-----------------------------.                  
  147.            .                             .                  
  148.          .---.         .-----------------------------------.
  149.          .   .         .                                   .
  150.        fact .--.  .----------.                            ()
  151.             .  .  .          .                              
  152.             n () if  .---------------.                      
  153.                      .               .                      
  154.                     .--.     .---------------.              
  155.                     .  .     .               .              
  156.                     < .--.   1     .--------------------.   
  157.                       .  .         .                    .   
  158.                       n .--.   .--------.              ()   
  159.                         .  .   .        .                   
  160.                         2 ()   * .-------------.            
  161.                                  .             .            
  162.                                  n       .-----------.      
  163.                                          .           .      
  164.                                      .-------.      ()      
  165.                                      .       .              
  166.                                    fact  .--------.         
  167.                                          .        .         
  168.                                         .--.     ()         
  169.                                         .  .                
  170.                                         - .--.              
  171.                                           .  .              
  172.                                           n .--.            
  173.                                             .  .            
  174.                                             1 ()            
  175. #[undefined]
  176.  
  177.  
  178.  
  179. Gambit Compiler
  180. ---------------
  181.  
  182. The Gambit Compiler (GSC for short) is used to compile a Scheme source
  183. program into a binary `object file' that can either be loaded by the
  184. Gambit Interpreter or turned into a full fledged Macintosh application
  185. with the Gambit Linker.
  186.  
  187. GSC needs at least 2.5 Megs to run.  A larger memory size is recommended
  188. to compile large Scheme programs.  If you do not have enough memory to
  189. compile a given program, split it into smaller files.
  190.  
  191. When launched, GSC will pop up a dialog box.  It is through this dialog
  192. box that you specify what file you want to compile and what compilation
  193. options to use.  The first parameter is the filename of the source file
  194. (you do not have to specify the extension `.scm').  The remaining
  195. parameters are the compilation options.
  196.  
  197. These options are accepted by GSC
  198.  
  199. verbose   Generate a trace of the compiler's actions on
  200.           the interaction window.
  201.  
  202. report    Produce global variable usage report on the
  203.           interaction window.  Each global variable used in
  204.           the program is listed with 4 flags that indicate if
  205.           the global variable is defined, referenced, mutated
  206.           and called.
  207.  
  208. asm       Produce the assembly language file on <source>.s .
  209.  
  210. pvm       Produce a listing of the PVM code for the program
  211.           on <source>.pvm .
  212.  
  213. stats     Generate code to gather runtime statistics on the
  214.           program.  The statistics will be output on the profile
  215.           file when the program is run.
  216.  
  217.  
  218. In addition to the standard Scheme special forms, the compiler accepts
  219. the following forms which can appear anywhere a `define' special form
  220. can appear:
  221.  
  222. (##declare <decl>...)
  223.  
  224.   See below for the list of accepted declarations.
  225.   The scope of the declaration extends to the end of the body it is in
  226.   or to the end of the program if it is at toplevel.
  227.  
  228. (##include "prog.scm")
  229.  
  230.   Read the expressions contained in the given file and splice them
  231.   into the program.
  232.  
  233. (##define-macro (name parm...) <body>)
  234.  
  235.   Define the name as a macro special form which expands into `body'.
  236.   The scope of the declaration extends to the end of the body it is in
  237.   or to the end of the program if it is at toplevel (unless it is
  238.   redefined before).
  239.  
  240.  
  241. The following declarations are accepted by the compiler:
  242.  
  243. (<dialect>)
  244.  
  245.   Use the given dialect's semantics.  <dialect> can be:
  246.   ieee-scheme, r4rs-scheme or multischeme.
  247.  
  248. ([not] lambda-lift)
  249.  
  250.   Lambda-lift (or don't lambda-lift) procedures.
  251.  
  252. (<strategy>)
  253.  
  254.   Select block compilation or separate compilation.  In block
  255.   compilation, the compiler can assume that all references to the
  256.   global variables defined in the current program are located in the
  257.   program itself.  <strategy> can be: block or separate.
  258.  
  259. ([not] standard-bindings <var>...)
  260.  
  261.   The given global variables are known (or not known) to be equal
  262.   to the value defined for them in the dialect (all variables defined
  263.   in the standard if none specified).
  264.  
  265. ([not] extended-bindings <var>...)
  266.  
  267.   The given global variables are known (or not known) to be equal
  268.   to the value defined for them in the runtime system (all variables
  269.   defined in the runtime if none specified).
  270.  
  271. ([not] safe)
  272.  
  273.   Generate (or don't generate) code that will prevent fatal runtime
  274.   errors.  Note that in `safe' mode certain semantic errors will not be
  275.   checked as long as they can't crash the system.  For example
  276.   the primitive `char=?' could disregard the type of its arguments in
  277.   `safe' (as well as `not safe') mode.
  278.  
  279. ([not] intr-checks)
  280.  
  281.   Generate (or don't generate) interrupt checks.  Interrupt checks are
  282.   used to signal the need for a garbage collection, to catch user
  283.   interrupts and also to check for stack overflows.  Interrupt checking
  284.   should not be turned off casually.
  285.  
  286. (<number-type> <prim>...)
  287.  
  288.   Numeric arguments and result of specified primitives are known to be
  289.   of the given type (all primitives if none specified).
  290.   <number-type> can be: generic or fixnum.
  291.  
  292.  
  293. The default declarations used by the compiler are:
  294.  
  295.   (ieee-scheme)
  296.   (lambda-lift)
  297.   (separate)
  298.   (not standard-bindings)
  299.   (not extended-bindings)
  300.   (not safe)
  301.   (intr-checks)
  302.   (generic)
  303.  
  304. These declarations are compatible with the IEEE-Scheme standard.
  305. Typically used declarations that enhance performance (at the cost of
  306. violating the IEEE-Scheme standard) are: (standard-bindings) and
  307. (fixnum).
  308.  
  309. The diagnostic messages produced by GSC are printed on the interaction
  310. window.
  311.  
  312. The code generated by GSC is very efficient.  Speedups of a factor of 100
  313. over interpreted code are not uncommon.
  314.  
  315.  
  316. A useful feature of object files is that they can be run by
  317. double-clicking them.  This is essentially equivalent to starting the
  318. interpreter and loading the given object file (except that the
  319. "init.scm" file is not loaded and a REP loop is not entered).
  320. As an example, exit from GSI and double-click the document file "pi.O".
  321.  
  322.  
  323. Gambit Linker
  324. -------------
  325.  
  326. The Gambit Linker is used to build a Macintosh application program
  327. from a runtime library and an arbitrary number of object files
  328. produced by the Gambit compiler.  The Gambit linker first prompts for
  329. the runtime library file and then for a set of object files.  The name
  330. of the application is the same as the name of the last object file to
  331. be linked with its `.O' extension stripped off.  For example, if you
  332. link the library `Runtime' with the object file `pi.O' you will get
  333. the application `pi' which you can then double-click to run.
  334.  
  335. When the linked program is launched, the effect is similar to loading
  336. each of the object files, in sequence, in the interpreter (except that
  337. the "init.scm" file is not loaded and a REP loop is not entered).
  338.